import {BasicColumn} from '/@/components/Table';
import {FormSchema} from '/@/components/Table';
import { rules} from '/@/utils/helper/validator';
import { render } from '/@/utils/common/renderUtils';
//列表数据
export const columns: BasicColumn[] = [
  {
    title: '主键',
    align: "center",
    dataIndex: 'id',
    width:220
  },
  {
    title: '小说ID',
    align: "center",
    dataIndex: 'bookId',
    width:220
  },
  {
    title: '目录号',
    align: "center",
    dataIndex: 'indexNum'
  },
  {
    title: '目录名',
    align: "center",
    dataIndex: 'indexName'
  },
  {
    title: '字数',
    align: "center",
    dataIndex: 'wordCount'
  },
  {
    title: '是否收费',
    align: "center",
    dataIndex: 'isVip',
    customRender:({text}) => {
       return  text?'收费':'免费'
     },
  },
  {
    title: '章节费用（屋币）',
    align: "center",
    dataIndex: 'bookPrice'
  },
  {
    title: '存储方式',
    align: "center",
    dataIndex: 'storageType'
  },
  {
    title: '创建时间',
    align: "center",
    dataIndex: 'createTime'
  },
];
columns.forEach(item=>{
  item.resizable=true
})
//查询数据
export const searchFormSchema: FormSchema[] = [
  {
    label: "小说ID",
    field: 'bookId',
    component: 'Input',
    colProps: {span: 6},
  },
];

//表单数据
export const formSchema: FormSchema[] = [
  {
    label: '小说ID',
    field: 'bookId',
    component: 'InputNumber',
    dynamicRules: ({model,schema}) => {
      return [
              { required: true, message: '请输入小说ID!'},
             ];
    },
  },
  {
    label: '目录号',
    field: 'indexNum',
    component: 'InputNumber',
    dynamicRules: ({model,schema}) => {
      return [
              { required: true, message: '请输入目录号!'},
             ];
    },
  },
  {
    label: '目录名',
    field: 'indexName',
    component: 'Input',
  },
  {
    label: '字数',
    field: 'wordCount',
    component: 'InputNumber',
  },
  {
    label: '是否收费',
    field: 'isVip',
    component: 'JSwitch',
    componentProps:{
    },
  },
  {
    label: '章节费用（屋币）',
    field: 'bookPrice',
    component: 'InputNumber',
  },
  {
    label: '存储方式',
    field: 'storageType',
    component: 'Input',
    dynamicRules: ({model,schema}) => {
      return [
              { required: true, message: '请输入存储方式!'},
             ];
    },
  },
	// TODO 主键隐藏字段，目前写死为ID
  {
    label: '',
    field: 'id',
    component: 'Input',
    show: false,
  },
];
